package com.example.demo.mapper;

import com.example.demo.entity.Company;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CompanyMapper {

    @Insert("insert into company(Cid, Cname, Cmanager, Cmphonenumber, Cfreedays, Cbelong, Crate) values (#{Cid}, #{Cname}, #{Cmanager}, #{Cmphonenumber}, #{Cfreedays}, #{Cbelong}, #{Crate})")
    int createCompany(Company company);

    @Delete("delete from company where Cid = #{Cid}")
    int deleteCompany(Integer Cid);

    @Update("update company set Isdeleted = 1 where Cid = #{Cid}")
    void updateIsdeleted(Integer Cid);

    @Update("update company set Cname = #{Cname}, Cmanager = #{Cmanager}, Cmphonenumber = #{Cmphonenumber},Cfreedays = #{Cfreedays}, Cbelong = #{Cbelong}, Crate = #{Crate} where Cid = #{Cid}")
    int updateCompany(Company company);

    @Select("select * from company where Cid = #{Cid} and Isdeleted = 0")
    Company findCompany(Integer Cid);

    @Select("select * from company where Isdeleted = 0")
    List<Company> findAllcompanies();
}
